package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.MarketAd;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AdService;
import com.fasterxml.jackson.databind.ser.Serializers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yaml.snakeyaml.error.Mark;
import sun.misc.Request;

import javax.servlet.http.HttpServletRequest;

/***
 * title AdminAdController
 * @description <TODO description class purpose>
 * @author ZCZ
 * @version 1.0.0
 * @create 2022/9/7 20:22
 **/
@RestController
@RequestMapping("admin/ad")
public class AdminAdController {
    @Autowired
    AdService adService;

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info,String name,String content){
      CommonData<MarketAd> data = adService.getAllAdInfo(info,name,content);
      return BaseRespVo.ok(data);
    }
    //响应格式有问题。
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MarketAd marketAd){


        MarketAd marketAd1=adService.creat(marketAd);
        return BaseRespVo.ok(marketAd1);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketAd marketAd){
        adService.delete(marketAd.getId());
        return BaseRespVo.ok3();
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketAd marketAd){
        MarketAd marketAd1 = adService.update(marketAd);
        return  BaseRespVo.ok(marketAd1);
    }




}
